<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>烟叶通道等级管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        body {
            background-color: #f8f5f0;
            background-image: url('');
            min-height: 100vh;
            padding: 0; /* 移除页面默认内边距 */
        }
        .container {
            width: 100%; /* 改为100%宽度 */
            margin: 0; /* 移除外边距 */
            background: white;
            border-radius: 0; /* 取消圆角 */
            box-shadow: 0 4px 20px rgba(101, 67, 33, 0.1);
            overflow: hidden;
            border: none; /* 取消边框 */
            transition: all 0.3s ease;
        }
        .header {
            background: linear-gradient(135deg, #8B4513 0%, #6d4c41 100%);
            color: #fff8e1;
            padding: 20px 30px;
            position: relative;
            overflow: hidden;
        }
        .header::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-image: url('');
            opacity: 0.1;
        }
        .header-content {
            position: relative;
            display: flex;
            align-items: center;
        }
        .tobacco-icon {
            width: 40px;
            height: 40px;
            margin-right: 15px;
            background-image: url('');
            background-size: contain;
            background-repeat: no-repeat;
            transition: transform 0.3s ease;
        }
        .header-content:hover .tobacco-icon {
            transform: rotate(5deg) scale(1.05);
        }
        .header h1 {
            font-size: 1.8rem;
            font-weight: 600;
            text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
        }
        .table-container {
            padding: 30px;
            overflow-x: auto;
            position: relative;
        }
        .table-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 2px solid #e8d9c5;
        }
        .table-title {
            color: #6d4c41;
            font-size: 1.3rem;
            font-weight: 600;
            display: flex;
            align-items: center;
        }
        .table-title::before {
            content: '';
            width: 24px;
            height: 24px;
            margin-right: 10px;
            background-image: url('');
            background-size: contain;
            display: inline-block;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            background-color: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 2px 10px rgba(101, 67, 33, 0.05);
            transition: box-shadow 0.3s ease;
        }
        table:hover {
            box-shadow: 0 4px 15px rgba(101, 67, 33, 0.1);
        }
        th, td {
            padding: 14px 18px;
            text-align: left;
            border-bottom: 1px solid #f0e6d8;
            transition: background-color 0.2s ease;
        }
        th {
            background: linear-gradient(180deg, #f8f2e9 0%, #f0e6d8 100%);
            color: #5d4037;
            font-weight: 600;
            position: sticky;
            top: 0;
            z-index: 10;
            border-bottom: 2px solid #e0d2c0;
            white-space: nowrap;
        }
        tr:hover {
            background-color: #fcf9f5;
        }
        tr:nth-child(even) {
            background-color: #fefbf7;
        }
        .edit-btn {
            display: inline-block;
            padding: 8px 16px;
            background: linear-gradient(135deg, #8D6E63 0%, #6d4c41 100%);
            color: white;
            border-radius: 6px;
            text-decoration: none;
            font-size: 0.9rem;
            transition: all 0.2s;
            box-shadow: 0 2px 5px rgba(101, 67, 33, 0.2);
            border: none;
            cursor: pointer;
            font-family: inherit;
        }
        .edit-btn:hover {
            background: linear-gradient(135deg, #6d4c41 0%, #5d4037 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(101, 67, 33, 0.3);
        }
        .edit-btn:active {
            transform: translateY(0);
            box-shadow: 0 2px 3px rgba(101, 67, 33, 0.2);
        }
        .status-badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 15px;
            font-size: 0.85rem;
            color: white;
            font-weight: 500;
            background-color: #8D6E63;
            box-shadow: 0 1px 3px rgba(101, 67, 33, 0.2);
            transition: all 0.2s;
        }
        .status-badge:hover {
            transform: scale(1.05);
        }
        .timestamp {
            font-size: 0.85rem;
            color: #795548;
        }
        .table-footer {
            margin-top: 20px;
            padding-top: 15px;
            border-top: 2px solid #e8d9c5;
            color: #6d4c41;
            font-size: 0.9rem;
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
        }
        .tobacco-leaf {
            position: absolute;
            opacity: 0.03;
            z-index: 0;
            transition: opacity 0.5s ease;
        }
        .tobacco-leaf:hover {
            opacity: 0.06;
        }
        .leaf-1 {
            top: 10%;
            right: 5%;
            width: 150px;
            height: 150px;
            background-image: url('');
            background-size: contain;
            background-repeat: no-repeat;
        }
        .leaf-2 {
            bottom: 10%;
            left: 5%;
            width: 120px;
            height: 120px;
            background-image: url('');
            background-size: contain;
            background-repeat: no-repeat;
        }
        .query-condition {
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
        }
        .query-condition form {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 10px;
        }
        .query-condition label {
            color: #6d4c41;
            font-weight: 500;
        }
        .query-condition select {
            padding: 6px 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            color: #5d4037;
            transition: border-color 0.2s;
        }
        .query-condition select:focus {
            border-color: #8D6E63;
            outline: none;
            box-shadow: 0 0 0 2px rgba(141, 110, 99, 0.1);
        }
        .channel-stats {
            margin-bottom: 15px;
            padding: 15px;
            background-color: #fefbf7;
            border-radius: 6px;
            border: 1px solid #f0e6d8;
            transition: all 0.3s;
            display: flex;
            flex-wrap: wrap;
            gap: 15px 25px;
        }
        .channel-stats:hover {
            border-color: #e0d2c0;
            box-shadow: 0 2px 8px rgba(101, 67, 33, 0.05);
        }
        .channel-stats span {
            color: #6d4c41;
            font-weight: 500;
            position: relative;
            padding-left: 20px;
        }
        .channel-stats span::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: #8D6E63;
            opacity: 0.7;
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            .header h1 {
                font-size: 1.5rem;
            }
            .table-container {
                padding: 15px;
            }
            .table-title {
                font-size: 1.1rem;
            }
            th, td {
                padding: 10px 12px;
                font-size: 0.9rem;
            }
            .edit-btn {
                padding: 6px 12px;
                font-size: 0.8rem;
            }
            .table-footer {
                flex-direction: column;
                gap: 5px;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <div class="header-content">
            <div class="tobacco-icon"></div>
            <h1>烟叶通道等级管理系统</h1>
        </div>
        <div class="tobacco-leaf leaf-1"></div>
    </div>
    <div class="table-container">
        <div class="table-header">
            <div class="table-title">通道等级配置列表</div>
        </div>

        <!-- 新增统计时间查询条件 -->
        <div class="query-condition">
            <form th:action="@{/channel/list}" method="get">
                <label>统计范围：</label>
                <select name="timeRange">
                    <option value="today" th:selected="${timeRange == 'today'}">当日</option>
                    <option value="total" th:selected="${timeRange == 'total' || timeRange == null}">总计</option>
                </select>
                <button type="submit" class="edit-btn">查询</button>
            </form>
        </div>

        <!-- 通道统计行 -->
        <div class="channel-stats">
            <span th:each="stat : ${channelStats}">
                通道[[${stat.channelNumber}]]：[[${stat.packageCount}]]包
            </span>
        </div>

        <table>
            <tr>
                <th>通道ID</th>
                <th>IO控制器IP</th>
                <th>IO控制器端口</th>
                <th>IO设备地址</th>
                <th>读卡器IP</th>
                <th>读卡器端口</th>
                <th>显示器IP</th>
                <th>显示器端口</th>
                <th>目标等级</th>
                <th>更新时间</th>
                <th>操作</th>
            </tr>
            <tr th:each="channel : ${channels}">
                <td th:text="${channel.channelId}"></td>
                <td th:text="${channel.ioIp}"></td>
                <td th:text="${channel.ioPort}"></td>
                <td th:text="${channel.ioDeviceAddr}"></td>
                <td th:text="${channel.rfidIp}"></td>
                <td th:text="${channel.rfidPort}"></td>
                <td th:text="${channel.displayIp}"></td>
                <td th:text="${channel.displayPort}"></td>
                <td>
                    <span class="status-badge" th:text="${channel.targetGrade}"></span>
                </td>
                <td class="timestamp" th:text="${#dates.format(channel.updateTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
                <td>
                    <a th:href="@{/channel/edit/{id}(id=${channel.channelId})}" class="edit-btn">修改配置</a>
                </td>
            </tr>
        </table>
        <div class="table-footer">
            <div>系统提示：所有通道配置将实时影响烟叶分拣流程</div>
            <div>数据更新时间：<span th:text="${#dates.format(new java.util.Date(), 'yyyy-MM-dd HH:mm:ss')}"></span></div>
        </div>
        <div class="tobacco-leaf leaf-2"></div>
    </div>
</div>
</body>
</html>